package com.zy.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;
import java.util.function.Function;

@Configuration
public class UserTools {
    @Autowired
    private UserService userService;

    public  record DeleteUser(String deleteByName) {
    }
    @Bean
    @Description("处理删除用户信息，只需要提供用户名")
    public Function<DeleteUser, String> deleteUserFunction(){
        System.out.println("deleteUserFunction");
        return deleteUser->{
            System.out.println("Deleting user: " + deleteUser.deleteByName());
            userService.deleteByName(deleteUser.deleteByName());
            return "删除成功";
        };
    }
}
